package com.gpagers.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.gpagers.model.User;
import com.gpagers.model.UserExample;

@Controller
public class IndexController extends BaseController{
	
	@RequestMapping(value = "/") 
	public ModelAndView toindexPagepre(HttpServletRequest request,
			HttpServletResponse response) {    
		ModelAndView mv = new ModelAndView();
		mv.setViewName("redirect:/index");
		return mv;
	}

	@RequestMapping(value = "index") 
	public ModelAndView toindexPage(HttpServletRequest request,
			HttpServletResponse response) {    
		ModelAndView mv = new ModelAndView();
		mv = createLayoutView("custom/index.vm");
		mv.addObject("curNav", "_h_index");
		return mv;
	} 

	@RequestMapping(value = "errorPagex",method=RequestMethod.GET)
	public ModelAndView errorPagex(HttpServletRequest request,
			HttpServletResponse response) {    
		ModelAndView mv = new ModelAndView();
		mv.setViewName("error/404_13");
		return mv;
	}
	
	@RequestMapping(value = "errorPage",method=RequestMethod.GET)
	public ModelAndView errorPage(HttpServletRequest request,
			HttpServletResponse response) {    
		ModelAndView mv = new ModelAndView();
		mv.setViewName("forward:/errorPagex");
		return mv;
	}
	
	@RequestMapping(value = "ueditorView") 
	public ModelAndView ueditorView(HttpServletRequest request,
			HttpServletResponse response) {    
		ModelAndView mv = new ModelAndView();
		mv = createLayoutView("ueditor/layout.vm");
		mv.addObject("curNav", "_h_ueditor");
		return mv;
	} 
	
	@RequestMapping(value = "mybatisView") 
	public ModelAndView mybatis(HttpServletRequest request,
			HttpServletResponse response) {    
		ModelAndView mv = new ModelAndView();
		mv = createLayoutView("mybatis/layout.vm");
		List<User> list = userMapper.selectByExample(new UserExample());
		mv.addObject("list_user", list);
		mv.addObject("curNav", "_h_mybatis");
		return mv;
	}
	
	@RequestMapping(value = "slf4jView") 
	public ModelAndView slf4jView(HttpServletRequest request,
			HttpServletResponse response) {  
		ModelAndView mv = new ModelAndView();
		mv = createLayoutView("slf4j/layout.vm");
		mv.addObject("curNav", "_h_slf4j");
		return mv;
	}
	
	@RequestMapping(value = "luceneViem") 
	public ModelAndView luceneView(HttpServletRequest request,
			HttpServletResponse response) {  
		ModelAndView mv = new ModelAndView();
		mv = createLayoutView("lucene/layout.vm");
		mv.addObject("curNav", "_h_lucene");
		return mv;
	}
} 